unit ComponentManagerUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IniFiles;

type
  TComponentManager = class
    CheckBox: array [1 .. 6] of TCheckBox;
    Names: array [1 .. 6] of string;
    // ButtonClear : TButton;
    // ButtonVote : TButton;
    procedure ButtonClearClick(Sender: TObject);
    procedure ButtonVoteClick(Sender: TObject);
  end;

implementation

procedure TComponentManager.ButtonClearClick;
var
  I: Integer;
begin
  for I := 1 to 6 do
    CheckBox[I].Checked := False;
end;

procedure TComponentManager.ButtonVoteClick;
var
  I, CheckedCount: Integer;
  Ini: TIniFile;
begin
  Ini := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'config.ini');

  CheckedCount := 0;
  for I := 1 to 6 do
    if (CheckBox[I].Checked = True) then
      CheckedCount := CheckedCount + 1;
  if (CheckedCount < 4) then
  begin
    for I := 1 to 6 do
      if (CheckBox[I].Checked = True) then
      begin
        Ini.WriteInteger('COUNTERS', IntToStr(I), Ini.ReadInteger('COUNTERS',
            IntToStr(I), 0) + 1);
        CheckBox[I].Checked := False;
      end;
    Ini.WriteInteger('COUNTERS', 'Total', Ini.ReadInteger('COUNTERS', 'Total',
        0) + CheckedCount);
  end
  else
  begin
    for I := 1 to 6 do
      CheckBox[I].Checked := False;
    Ini.WriteInteger('COUNTERS', 'Invalid', Ini.ReadInteger('COUNTERS',
        'Invalid', 0) + 1);
  end; (((Sender as TButton).Parent) as TForm)
  .Close();
end;

end.
